package com.web.kdl.service.createTable.factory;

import com.web.kdl.service.createTable.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author： shulibin
 * @Date： 2025/8/21 18:10
 * @Describe：
 */
@Component
public class FlywheelTableFactory implements TableFactory {

    @Autowired
    private AlertTable alertTable;

    @Autowired
    private StatusTable statusTable;
    @Override
    public FlywheelTable createTable(String siteName,String matrixName, String flywheelName, TableType type) {
        switch (type) {
            case ALERT:
                return new AlertTable(siteName,matrixName, flywheelName);
            case STATUS:
                return new StatusTable(siteName,matrixName, flywheelName);
            default:
                throw new IllegalArgumentException("Unknown table type: " + type);
        }
    }

    @Override
    public FlywheelTable createDataTable(String siteName, String matrixName, String flywheelName, TableDataType type) {
        return new DataTable(siteName, matrixName, flywheelName,type);
    }


    @Override
    public FlywheelTable deleteTable(String siteName,String matrixName, String flywheelName, TableType type) {
        switch (type) {
            case ALERT:
                return new AlertTable(siteName,matrixName,flywheelName);
            case STATUS:
                return new StatusTable(siteName,matrixName,flywheelName);
            default:
                throw new IllegalArgumentException("Unknown table type: " + type);
        }
    }

    @Override
    public FlywheelTable deleteDataTable(String siteName, String matrixName, String flywheelName, TableDataType type) {
        return new DataTable(siteName, matrixName, flywheelName,type);
    }
}
